#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n,m,tag[100001][3],ans1=0,ans2=1;
        int l,v;
        cin>>n>>m>>l>>v;
        float c[100001][4],t[100001];
        for(int j=1;j<=n;j++)
        {
            cin>>c[j][1]>>c[j][2]>>c[j][3];//d>>v>>a
        }
        for(int j=1;j<=m;j++)cin>>t[j];
        int maxn=t[1];
        for(int j=1;j<=m;j++)
        {
            if(t[j]>maxn)maxn=t[j];
        }
        for(int j=1;j<=n;j++)
        {
            if(c[j][2]>v&&c[j][1]<=maxn)ans1++;
        }
        if(ans1==0)ans2=0;
        cout<<ans1<<" "<<m-ans2<<endl;
    }
    return 0;
}
